'''
Created on Nov 26, 2012

@author: shraybansal
'''

from DTW_win import DTW, DTWOne

class DistanceRow():
    """DTW Vector-
    GesName
    ExampleNo.
    CompareWith- Gesture
    Distances={one of accNorm, acc3, both, or ang3}"""
    
    def __init__(self, gestName, examNo, cmpGes, cmpExNo):
        """Constructor"""
        self.mallGest = gestName
        self.mallExamp = examNo
        self.yallGest = cmpGes
        self.yallExamp = cmpExNo
        self.dist=0
    
    def setCompGes(self, gestName):
        """Set gesture name for example in comparison"""
        self.yallGest = gestName
    
    def setCompEx(self, examNo):
        """Set example no. for example in comparison"""
        self.yallExamp = examNo
        
    def setDist(self, distance):
        """Set example no. for example in comparison"""
        self.dist = distance
    
    def returnAlla(self):
        return [self.mallGest, self.mallExamp, self.yallGest, self.yallExamp, self.dist]        
    
    def returnDist(self):
        return self.dist
        
    def findAccNormDist(self, featureVec, query):
        "Find DTW dist using the acceleration norm"
        
        """If example no. and gesture are same as the gesture to be compared with then dist is zero"""
        if (self.mallExamp==self.yallExamp and self.mallGest==self.mallGest):
            self.dist=0.0
        elif not(self.yallGest==[] or self.yallExamp==[] or featureVec==[]):
            self.dist=DTWOne(featureVec, query)
        else:
            print self.mallGest,' ', self.mallExamp,' compared with ', self.yallGest, ' ', self.yallExamp,' . See the Problem(Acc Norm)?'

    def findAcc3Dist(self, featureVec, query):
        "Find DTW dist using the acceleration in 3 dim"
        
        """If example no. and gesture are same as the gesture to be compared with then dist is zero"""
        if (self.mallExamp==self.yallExamp and self.mallGest==self.mallGest):
            self.dist=0.0
        elif not(self.yallGest==[] or self.yallExamp==[] or featureVec==[]):
            self.dist=DTW(featureVec, query)
        else:
            print self.mallGest,' ', self.mallExamp,' compared with ', self.yallGest, ' ', self.yallExamp,' . See the Problem(Acc 3)?'

    def findAng3Dist(self, featureVec, query):
        "Find DTW dist using the angular velocity in 3 dim"
        
        """If example no. and gesture are same as the gesture to be compared with then dist is zero"""
        if (self.mallExamp==self.yallExamp and self.mallGest==self.mallGest):
            self.dist=0.0
        elif not(self.yallGest==[] or self.yallExamp==[] or featureVec==[]):
            self.dist=DTW(featureVec, query)
        else:
            print self.mallGest,' ', self.mallExamp,' compared with ', self.yallGest, ' ', self.yallExamp,' . See the Problem(Ang 3)?'

    def findAccAngBoth(self, featureVec, query):
        "Find DTW dist using the acceleration in 3 dim"
        
        """If example no. and gesture are same as the gesture to be compared with then dist is zero"""
        if (self.mallExamp==self.yallExamp and self.mallGest==self.mallGest):
            self.dist=0.0
        elif not(self.yallGest==[] or self.yallExamp==[] or featureVec==[]):
            self.dist=DTW(featureVec, query)
        else:
            print self.mallGest,' ', self.mallExamp,' compared with ', self.yallGest, ' ', self.yallExamp,' . See the Problem(Both)?'